package com.zsrt.day20170417.am.AnimalShop.animaldaoimpl;


import com.zsrt.day20170417.am.AnimalShop.dao.AnimalDao;
import com.zsrt.day20170417.am.AnimalShop.entity.AnimalEntity;

/**
*@author jzh
*@创建时间 2017年4月17日上午11:54:19
*类说明：
*/
public class AnimalDaoImpl implements AnimalDao{
	
	
	/**
	 * 增加一只动物
	 */
	@Override
	public void addAnimal(AnimalShop animalShop,AnimalEntity animal ){
		AnimalEntity[] lz = animalShop.getLz();
		int counter=0;
		for(int index=0;index<lz.length;index++){
			AnimalEntity dongwu =lz[index];
			if(dongwu!=null){
				counter++;
			}else{
				break;
			}
		}
		if(counter>=lz.length){
			System.out.println("笼子已满");
		}else{
			lz[counter]=animal;
			System.out.println("还有"+(lz.length-counter-1)+"个位置");
		}	
	}
	
	

	@Override
	public void addAnimals(AnimalShop animalShop, AnimalEntity[] animals) {
		
		for(int index=0;index<animals.length;index++){
			addAnimal(animalShop, animals[index]);
		}
		
	}

}
